package com.spring.security.study.security_test.utils;

import com.spring.security.study.security_test.api.SysUser;
import com.spring.security.study.security_test.api.SysUserDetails;
import com.spring.security.study.security_test.service.SysUserService;
import lombok.AllArgsConstructor;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @ClassName : SysUserUtils
 * @Author : lby
 * @Date: 2021/1/26 15:04
 * @Description : 当前登陆
 */
@Component
public class SysUserUtils {
    /**
     * 当前登录人
     * @return
     */
    public static String getUser(){
        SysUserDetails sysUser = (SysUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return sysUser.getUserId()  ;
    }
}
